//package com.studerb.old;
//
//import org.apache.log4j.*;
//
//import com.studerb.exceptions.*;
//import com.studerb.util.Constants;
//import com.studerb.service.*;
//import java.sql.*;
//
///**
// * Sets up the main settings for the application
// * including the logging, properties, databases, etc
// */
//public class AppSetup {
//
//    private Logger logger;
//    
//
//    public  AppSetup(){
//	logger = Logger.getLogger(Constants.APP_NAME + "." + AppSetup.class.getName());
//    }
//
//    public void setup() throws AppKillerException {
//	setupSettings();
//	setupDB();
//    }
//
//    private void setupDB() throws AppKillerException {
//	try {
//	    logger.debug("Setting up Hibernate...");
//	    Class.forName("com.studerb.util.HibernateUtil");
//	}
//	catch(ClassNotFoundException ex){
//	    logger.error("Error setting up Hibernate: " + ex.getMessage());
//	    throw new AppKillerException("Error setting up Database...", ex);
//	}
//
////	dbDriver = Settings.getSetting("derby.driver");
////	dbUrl = Settings.getSetting("derby.url");
////	logger.debug("Setting up the database driver " + dbDriver);
////	try {
////	Class.forName(dbDriver);
////	}
////	catch(ClassNotFoundException e){
////	logger.fatal("Unable to load database driver: " + dbDriver);
////	throw new AppKillerException("Unable to load database driver: " + dbDriver);
////	}
////	try {
////	logger.debug("Setting up hibernate mapping");
////	Class.forName(com.studerb.util.HibernateUtil.class.getName());
////	}
////	catch (Exception e){
////	logger.fatal("Unable to load hibernate: " + e.getMessage());
////	e.printStackTrace();
////	throw new AppKillerException("Unable to load hibernate");
////	}
//
//    }
//
//    private void shutdownDB(){
//	try {
//	    DriverManager.getConnection("jdbc.derby;shutdown=true");
//	}
//	catch (SQLException e) {
//	    logger.info("Database successfully shutdown");
//	}
//	catch (Exception ex) {
//	    logger.error("Error shutting down Database..." + ex.getMessage());
//	}
//    }
//
//
//    private void setupSettings() throws AppKillerException {
//	logger.debug("Setting up the settings");
//	try {
//	    Class.forName("com.studerb.util.Settings");
//	}
//	catch(ClassNotFoundException e) {
//	    logger.fatal("Error setting up the Settingse");
//	    throw new AppKillerException("Could not load class 'com.studerb.util.Settings'");
//	}
//    }
//
//    public void shutdown() throws AppKillerException{
//	logger.info("Shutting down App");
//	try {
//	    //shutdown the db
//	    shutdownDB();
//	    //flush all the settings out
//	    SettingsService.getInstance().flush();
//	}
//	catch (Exception ex) {
//	    logger.error("Error shutting down application");
//	    throw new AppKillerException("Error shutting down app.. "  + ex);
//	}
//    }
//}
